package com.streamer.app.adapter

import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.streamer.app.R

class EmojiAdapter(
    private val emojis: List<String>,
    private val onEmojiClick: (String) -> Unit
) : RecyclerView.Adapter<EmojiAdapter.EmojiViewHolder>() {

    class EmojiViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val tvEmoji: TextView = itemView.findViewById(R.id.tv_emoji)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojiViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.item_emoji, parent, false)
        Log.d("EmojiAdapter", "Creating view holder for position: $viewType")
        return EmojiViewHolder(view)
    }

    override fun onBindViewHolder(holder: EmojiViewHolder, position: Int) {
        val emoji = emojis[position]
        holder.tvEmoji.text = emoji
        Log.d("EmojiAdapter", "Binding emoji: $emoji at position: $position")
        holder.tvEmoji.setOnClickListener {
            onEmojiClick(emoji)
        }
    }

    override fun getItemCount(): Int {
        Log.d("EmojiAdapter", "Item count: ${emojis.size}")
        return emojis.size
    }
} 